// 引入路由依赖
import Vue from 'vue'
import VueRouter from 'vue-router'

// 引入Vue的页面组件
import Home from 'pages/Home'
import Category from 'pages/Category'
import Find from 'pages/Find'
import Shopcar from 'pages/Shopcar'
import Mine from 'pages/Mine'
import Login from 'common/Login'
import Search from 'common/Search'
import Details from 'common/Details'
import Error404 from 'common/Error404'

// Vue进行vue路由
Vue.use(VueRouter)

// 定义路由配置
const routes = [{
        path: '/',
        redirect: '/home'
    },
    //首页
    {
        path: '/home',
        name:'home',
        component: Home
    },
    // 分类页
    {
        path: '/category',
        component: Category
    },
    // 发现页
    {
        path: '/find',
        component: Find
    },
    // 购物车页
    {
        path: '/shopcar',
        name: 'shopcar',
        component: Shopcar
    },
    // 我的 页
    {
        path: '/mine',
        component: Mine
    },
    // 登录页
    {
        path: '/login',
        component: Login
    },
    // 搜索页
    {
        path: '/search',
        component: Search,
        name: 'search'
    },
    //详情页
    {
        path: '/details',
        component: Details,
        name: 'details'
    },
    {
        path: '*',
        component: Error404
    }
]

// 实例化路由
const router = new VueRouter({
    routes,
    mode: 'history'
})

export default router